package SSF.OS.TCP;
/**
 * SendItem.java
 *
 *
 * Created: Mon Jul 19 02:24:52 1999
 *
 * @version 0.4.5
 */
import SSF.OS.*;

/** A Send queue item is a wrapper around one tcp data segment in the send queue,
 *  including the TCP bookkeeping information such as the number of retransmissions
 *  and the time of last transmission of this data segment.
 */
public class SendItem {

  /** reference to the previous and next item in the send queue  */
  public SendItem next, prev;

  /** the TCP message in this item */
  public TCP_Message msg;

  /** previous send time of this packet*/
  float  prevSendTime;

  /** the number of time the message had been retransmitted*/
  public short rexTimes = 0;

  /* clear all fields, used in tcpMessagePool */
  void clear() {
    next = prev = null;
    msg = null;
    prevSendTime = 0.0F;
    rexTimes = 0;
  }
  
  /** get next sequence number of the data message in this item*/
  public long nextseqno(){
    if(((msg.flags & TCP_Header.SYN) != 0)
       || ((msg.flags & TCP_Header.FIN) != 0))
       return msg.SEQno + 1;
    else
       return (msg.SEQno + msg.seglen);
  }

  /** 
   * get the sequence number of the first byte of the data message in 
   * this item
   */
  public long seqno() {return msg.SEQno;}

  /** set the sequence number of the first byte of the data message in 
   * this item
   */
  public void setSEQno(long seq){
    msg.SEQno = seq;
  }

  /* 1/25/02 NOT USED
  public void setACKno(long ackno){
    msg.ACKno = ackno;
  }

  public void setAdvWnd(int wnd){
    msg.AdvertisedWnd = wnd;
  }
  */

  public int getMsgLen(){return msg.seglen;}

  
  /**
   * Get the value of prevSendTime.
   * @return Value of prevSendTime.
   */
  public float  getPrevSendTime() {return prevSendTime;}
  
  /**
   * Set the value of prevSendTime.
   * @param v  Value to assign to prevSendTime.
   */
  public void setPrevSendTime(float  v) {this.prevSendTime = v;}

  /** print out the content of the data message*/
  public void printItem(){
    msg.printMsg();
  }
}

